<template>
  <div class="rose-echart">
    <echarts :options="options"></echarts>
  </div>
</template>

<script setup lang="ts">
import Echarts from '@/base-ui/echarts'
import { computed, defineProps } from 'vue'
import { IDataType } from '../types'

const props = defineProps<{
  roseData: IDataType[]
}>()

const options = computed(() => {
  return {
    tooltip: {
      trigger: 'item',
      formatter: '{a} <br/>{b} : {c} ({d}%)'
    },
    legend: {
      left: 'center',
      top: 'bottom'
    },
    toolbox: {
      show: true,
      feature: {
        mark: { show: true },
        dataView: { show: true, readOnly: false },
        restore: { show: true },
        saveAsImage: { show: true }
      }
    },
    series: [
      {
        name: '分类商品数量',
        type: 'pie',
        radius: [8, 96],
        center: ['48%', '40%'],
        roseType: 'area',
        itemStyle: {
          borderRadius: 5
        },
        data: props.roseData
      }
    ]
  }
})
</script>

<style scoped></style>
